#include <iostream>
#include <thread>
#include <vector>
using namespace std;
void TF(vector<int> x, vector<int> y, int* ret){
assert(x.size()==y.size());
for(int i=0; i<x.size(); ++i) *ret+=x[i]*y[i];
}
vector<int> MatVec(vector<vector<int>> A, vector<int> x){
int n=A.size();
vector<int> y(n);
vector<thread> threads;
for(int i=0; i<n; ++i) y[i]=0;
for(int i=0; i<n; ++i){
threads.push_back(thread(TF, A[i], x, &y[i]));
}
for(int i=0; i<n; ++i) threads[i].join();
return y;
}
int main(void){
vector<vector<int>> A={
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9},
{1, 2, 3, 4, 5, 6, 7, 8, 9}, {1, 2, 3, 4, 5, 6, 7, 8, 9}
};
vector<int> x={9, 8, 7, 6, 5, 4, 3, 2, 1};
vector<int> y=MatVec(A, x);
for(int i=0; i<y.size(); ++i) std::cout<<y[i]<<' ';
std::cout<<std::endl;
return 0;
}